<?php

namespace Home\Model;

/*
 * EachGo电商网站 新媒体
 * www.eachgo.cn
 */

use Think\Model;

/*
 * 反馈
 */

class FeedbackModel extends Model {
    /*
     * 添加一条记录
     */

    public function addFeedback($obj) {
        //$data = D(Feedback);
        $res = $this->add($obj);

        return $res;
    }

    /*
     * 删除一条记录
     */

    public function deleteFeedback($obj) {
        
    }

    /*
     * 更新一条记录
     */

    public function updateFeedback($obj) {
        //$data = D(Feedback);
        $res = $this->where('userID = "' . $obj['userID'] . '" and employeeID = "' . $obj['employeeID'] . '"')->save($obj);

        return $res;
    }

    /*
     * 通过EmployeeId查找
     */

    public function selectFeedbackByEmployeeId($obj) {
        //$data = D('Feedback');
        $res = $this->where('employee_ID=' . $obj)->select();
        return $res;
    }

    /*
     * 通过feedbackText查找
     */

    public function selectFeedbackByFeedbackText($obj) {
        //$data = D('Feedback');
        $res = $this->where('feedback_Text like "%' . $obj . '%"')->select();
        return $res;
    }

    /*
     * 通过FeedbackTime查找
     */

    public function selectFeedbackByFeedbackTime($obj) {
        //$data = D('Feedback');
        $res = $this->where('feedback_Time=' . $obj)->select();
        return $res;
    }

    /*
     * 通过Period查找
     */

    public function selectFeedbackByTimePeriod($obj) {
        //$data = D('Feedback');
        $ti = $obj * 30;
        $startTime = date('Y-m-d H:i:s', strtotime('-' . $ti . ' day'));
        $res = $this->where('feedback_Time between "' . $startTime . '" and "' . date('Y-m-d H:i:s'))->select();

        return $res;
    }

}
